import javax.media.opengl.*;

public class Triangle extends PhysicsObject {
	private static final float[] VERTICES = {0, 0, 1, 0, 0, 1};
	
	private class Renderable extends SceneGraphNode {
		public void renderGeometry(GLAutoDrawable drawable) {
			GL2 gl = drawable.getGL().getGL2();
			
			gl.glColor3f(1, 1, 1);
			gl.glBegin(GL.GL_TRIANGLES);
			for (int i = 0; i < VERTICES.length; i += 2) {
				gl.glVertex2f(VERTICES[i], VERTICES[i+1]);
			}
			gl.glEnd();
		}
	}
	
	public Triangle(float size) {
		renderable = new Renderable();
		renderable.scale = size;
	}
	
	public Vector2f[] getVertices() {
		Vector2f[] vertices = new Vector2f[VERTICES.length / 2];
		for (int i = 0; i < VERTICES.length; i += 2) {
			vertices[i/2] = new Vector2f(VERTICES[i] * renderable.scale + position.x, VERTICES[i+1] * renderable.scale + position.y);
		}
		return vertices;
	}
}
